#include <config.h>
#include "st-private.h"
+#include "st-settings.h"
#include "st-texture-cache.h"
#include "st-theme.h"
#include "st-theme-context.h"
int scale_factor;
};
-#define DEFAULT_FONT "sans-serif 10"
-
enum
{
PROP_0,
G_DEFINE_TYPE (StThemeContext, st_theme_context, G_TYPE_OBJECT)
+static PangoFontDescription *get_interface_font_description (void);
+static void on_font_name_changed (StSettings *settings,
+ GParamSpec *pspec,
+ StThemeContext *context);
static void on_icon_theme_changed (StTextureCache *cache,
StThemeContext *context);
static void st_theme_context_changed (StThemeContext *context);
{
StThemeContext *context = ST_THEME_CONTEXT (object);
+ g_signal_handlers_disconnect_by_func (st_settings_get (),
+ (gpointer) on_font_name_changed,
+ context);
g_signal_handlers_disconnect_by_func (st_texture_cache_get_default (),
(gpointer) on_icon_theme_changed,
context);
static void
st_theme_context_init (StThemeContext *context)
{
- context->font = pango_font_description_from_string (DEFAULT_FONT);
+ context->font = get_interface_font_description ();
+ g_signal_connect (st_settings_get (),
+ "notify::font-name",
+ G_CALLBACK (on_font_name_changed),
+ context);
g_signal_connect (st_texture_cache_get_default (),
"icon-theme-changed",
G_CALLBACK (on_icon_theme_changed),
return context;
}
+static PangoFontDescription *
+get_interface_font_description (void)
+{
+ StSettings *settings = st_settings_get ();
+ g_autofree char *font_name = NULL;
+
+ g_object_get (settings, "font-name", &font_name, NULL);
+ return pango_font_description_from_string (font_name);
+}
+
static void
on_stage_destroy (ClutterStage *stage)
{
g_object_unref (old_root);
}
+static void
+on_font_name_changed (StSettings *settings,
+ GParamSpec *pspect,
+ StThemeContext *context)
+{
+ PangoFontDescription *font_desc = get_interface_font_description ();
+ st_theme_context_set_font (context, font_desc);
+
+ pango_font_description_free (font_desc);
+}
+
static gboolean
changed_idle (gpointer userdata)
{